package com.csair.platform.cit.service.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.csair.platform.cit.service.entity.CitDeclareRecord;


@Repository
public interface CitDeclareRecordRepository extends JpaRepository<CitDeclareRecord, Long>, JpaSpecificationExecutor<CitDeclareRecord> {

    @Query(value = "from CitDeclareRecord where status = '申报中' and jylsh is not null  ")
    List<CitDeclareRecord> findCitDeclareRecordByStatus();

    @Query(value = "from CitDeclareRecord where id in (:ids) ")
    List<CitDeclareRecord> findAllByIds(@Param("ids")List<Long> ids);
    
    @Transactional
    @Modifying
    @Query("delete from CitDeclareRecord where id in (:ids) ")
    int deleteByIds(@Param("ids")List<Long> ids);



    /**
     * 根据税号和税款属期查询
     * @param nsrsbh
     * @param skssqq
     * @param skssqz
     * @return
     */
    @Query(value = "from CitDeclareRecord where nsrsbh =?1 and    skssqq =?2 and skssqz =?3  and status='申报成功'")
    CitDeclareRecord findByTaxNoAndSkssAndStatusSuccess(String nsrsbh, String skssqq, String skssqz);
}